<?php

/**
 * @author FROSTY (valik619)
 * @site nadmad.ru
 * @mail valik619@inbox.ru
 */
 
$title = 'WBCMS - wap blogs CMS';

include('system/core.php');

if (!$uid) {
    header('Location: http://'.$set['home'].'/login.php');
    exit;
}

include('system/head.php');

$action=htmlspecialchars(trim($_GET['a']));

switch ($action){

default:
echo '<div class="title">'.$lang['cabinet'].'</div>';
echo '<div class="small"><div class="url"><a href="office.php?a=anketa">'.$lang['anketa'].'</a> | [<a href="office.php?a=zminutu">'.$lang['redaction'].'</a>]</div></div>';
echo '<div class="small"><a class="url" href="office.php?a=setting">'.$lang['setting'].'</a></div>';
if($rights == 1){
  echo '<div class="small"><a class="url" href="adm.php">'.$lang['panel'].'</a></div>';  
}

break;

case 'anketa':
$id = $_GET['id'];
if($id){
    $zz = mysql_query("SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1");
    $usr = mysql_fetch_assoc($zz);
}else $usr = $user;

echo ($id ? '<div class="title">'.$lang['anketa'].' '.$usr['nick'].'</div>' : '<div class="title">'.$lang['myanketa'].'</div>');
echo '<div id="imenu">';
echo "<div class='like'><img src='".functions::ava(''.$usr['mail'].'', 128, 'g', 'mm')."' alt='Gravatar'></div>";
echo '<div class="info">'.$lang['name'].': '.$usr['name'].'</div>';
echo '<div class="info">'.$lang['information'].': '.$usr['about'].'</div>';
echo '<div class="info">City: '.$usr['city'].'</div>';
echo '<div class="info">Mail: '.$usr['mail'].'</div>';
if($usr['vk']){
echo '<div class="info"><a href="http://vk.com/'.$usr['vk'].'">'.$usr['vk'].'</a></div>';
}else{
echo '<div class="info">'.$lang['vk_not_okay'].'</div>';
}
echo '</div>';

$ignorlist=mysql_result(mysql_query("SELECT COUNT(*) FROM `ignor` WHERE `uid` = '$id' AND `pid` = '$uid'"), 0);

if($id && $id != $uid && !$ignorlist){
    echo '<div class="title">'.$lang['other'].'</div>';
echo '<div class="small"><a class="url" href="mail/index.php?id='.$id.'">'.$lang['to_dialog'].'</a></div>';
}

$ignorlist1=mysql_result(mysql_query("SELECT COUNT(*) FROM `ignor` WHERE `pid` = '$id' AND `uid` = '$uid'"), 0);
if($id && $id != $uid){
if(!$ignorlist1){
echo '<div class="small"><a class="url" href="mail/index.php?a=ignor&amp;id='.$id.'">'.$lang['vignor'].'</a></div>'; 
}else{
echo '<div class="small"><a class="url" href="mail/index.php?a=delignor&amp;id='.$id.'">'.$lang['uignor'].'</a></div>';  
}
}
if($rights == 1)echo '<div class="small"> '.($pr ? '<a class="url" href="admin/useredit.php?id='.$id.'">' : '<a class="url" href="admin/useredit.php?id='.$uid.'">').''.$lang['redaction1'].'</a></div>';

echo '</div>';
break;


case 'zminutu':

echo '<div class="title">'.$lang['red_anketa'].'</div>';

if (isset($_POST['submit'])) {
    
$name = isset($_POST['name']) ? trim($_POST['name']) : '';
$mail = isset($_POST['email']) ? trim($_POST['email']) : '';
$vk = isset($_POST['vk']) ? trim($_POST['vk']) : '';
$city = isset($_POST['city']) ? trim($_POST['city']) : '';
$about = isset($_POST['about']) ? trim($_POST['about']) : ''; 

mysql_query("UPDATE `users` SET `name` = '$name' WHERE `id` = '$uid' LIMIT 1");
mysql_query("UPDATE `users` SET `mail` = '$mail' WHERE `id` = '$uid' LIMIT 1");
mysql_query("UPDATE `users` SET `vk` = '$vk' WHERE `id` = '$uid' LIMIT 1");
mysql_query("UPDATE `users` SET `city` = '$city' WHERE `id` = '$uid' LIMIT 1");
mysql_query("UPDATE `users` SET `about` = '$about' WHERE `id` = '$uid' LIMIT 1");


    echo '<div class="omenu">'.$lang['info_save'].'</div>';
    
}

    
echo '<div class="menu">';
echo '<form action="office.php?a=zminutu" method="post">';
echo ''.$lang['name'].':<br />';
echo '<input type="name" name="name" maxlength="30" value="'.$user['name'].'" /><br />';
echo ''.$lang['information'].':<br />';
echo '<textarea name="about" />'.$user['about'].'</textarea><br />';
echo 'City:<br />';
echo '<input type="name" name="city" maxlength="60" value="'.$user['city'].'" /><br />';
echo 'Email:<br />';
echo '<input type="name" name="email" maxlength="60" value="'.$user['mail'].'" /><br />';
echo 'vk.com/<br />';
echo '<input type="name" name="vk" maxlength="60" value="'.$user['vk'].'" /><br />';
echo '<input type="submit" name="submit" value="Save"/></form>';
echo '<p><a href="office.php?a=anketa">'.$lang['go_anketa'].'</a></p>';
echo '</div>';
    


break;





case 'setting':

echo '<div class="title">'.$lang['setting'].'</div>';

if (isset($_POST['submit'])) {
    
$design = isset($_POST['design']) ? trim($_POST['design']) : '';

mysql_query("UPDATE `users` SET `design` = '$design' WHERE `id` = '$uid' LIMIT 1");

$kolmess = isset($_POST['kmess']) ? trim($_POST['kmess']) : '';
if($kolmess > 3 || $kolmess < 99){ // на всякий випадок
mysql_query("UPDATE `users` SET `kmess` = '$kolmess' WHERE `id` = '$uid' LIMIT 1");
}
$mainmenu = isset($_POST['mainmenu']) ? trim($_POST['mainmenu']) : '';

mysql_query("UPDATE `users` SET `mainmenu` = '$mainmenu' WHERE `id` = '$uid' LIMIT 1");
  
    echo '<div class="omenu">'.$lang['info_save'].'</div>';
   }   
   
    
echo '<div id="imenu">';
echo '<div class="info">';
echo '<form action="office.php?a=setting" method="post">';

echo '<h3>Дизайн</h3><select name="design">';
$dir = opendir('design');
while ($design = readdir($dir)) {
    if (($design != '.') && ($design != '..') && ($design != '.svn')) {
        $design = str_replace('.css', '', $design);
        if($design != 'js.js'){ //Убираем из маассива я.с. файл
        echo '<option' . ($user['design'] == $design ? ' selected="selected">' : '>') . $design . '</option>';
    }}
}
closedir($dir);
echo '</select><br /><p>';
echo ''.$lang['kmess'].'<br />';
echo '<input type="number" name="kmess" max="99" value="'.$user['kmess'].'" /><br />';



if($set['general']){
if($user['mainmenu'] == 1){
echo '<p><div class="info"><input type="radio" name="mainmenu" value="1" checked><a href="files/images/1.png">'.$lang['mainmenu'].' №1</a></div></p>';
}else echo '<p><div class="info"><input type="radio" name="mainmenu" value="1"><a href="files/images/1.png">'.$lang['mainmenu'].' №1</a></div></p>';
if($user['mainmenu'] == 2){
echo '<p><div class="info"><input type="radio" name="mainmenu" value="2" checked><a href="files/images/2.png">'.$lang['mainmenu'].' №2</a></div></p>';
}else echo '<p><div class="info"><input type="radio" name="mainmenu" value="2"><a href="files/images/2.png">'.$lang['mainmenu'].' №2</a></div></p>';
if($user['mainmenu'] == 3){
echo '<p><div class="info"><input type="radio" name="mainmenu" value="3" checked><a href="files/images/3.png">'.$lang['mainmenu'].' №3</a></div></p>';
}else echo '<p><div class="info"><input type="radio" name="mainmenu" value="3"><a href="files/images/3.png">'.$lang['mainmenu'].' №3</a></div></p>';
//Пробачте за бидлокод...
                    }     
                         



echo '<input type="submit" name="submit" value="Save"/></form></p>';
echo '<p><a href="office.php?a=anketa">'.$lang['go_anketa'].'</a></p>';
echo '</div>';
echo '</div>';
    


break;

}

include('system/foot.php');

/**
 * @author FROSTY (valik619)
 * @site nadmad.ru
 * @mail valik619@inbox.ru
 */

?>